// 对await进行统一处理
//  const [err, data] = await awaitWrap(fetchData())
//  console.log('err', err)
//  console.log('data', data)

const customAwait = <T, U = any>(
  promise: Promise<T>
): Promise<[U | null, T | null]> => {
  return promise
    .then<[null, T]>((data: T) => [null, data])
    .catch<[U, null]>(err => [err, null]);
};
export default customAwait;
